/*
============================================================================
 Name        : PdImageDecoder.h
 Author      : Jian(raphyer@hotmail.com)
 Version     :
 Copyright   : GPL
 Description : CPdImageDecoder declaration
============================================================================
*/

#ifndef PDIMAGEDECODER_H
#define PDIMAGEDECODER_H

#include <f32file.h>    // RFs

/* Forward declaration */
class CFbsBitmap ;
class CImageDecoder ;
class CBitmapScaler ;


/**
*  CPdImageDecoder
* 
*/
class CPdImageDecoder : public CActive
{
public:

    ~CPdImageDecoder();

    static CPdImageDecoder* NewL(const TDesC& aFileName, const TSize& aSize) ;

    /* Note: aImageData ownship was transfer */
    static CPdImageDecoder* NewDataL(HBufC8* aImageData, const TSize& aSize) ;

private:

    CPdImageDecoder() ;

private:

    void _doInit(const TDesC& aFileName, const TSize& aSize) ;

    void _doInitData(HBufC8* aImageData, const TSize& aSize) ;

public:

    CFbsBitmap* Bitmap()const { return iBitmap ; } ;

    CFbsBitmap* Mask()const { return iMask; } ;

    TSize ImageSize()const { return iImageSize ; } ;

    TBool IsReady() const { return iDecodeFinish; } ;

private:    // From CActive

    void RunL();

    void DoCancel();

private:
    enum TState 
    {
        EDecoding = 0 ,
        EScaleBitmap,
        EScaleMask
    };

private:
    RFs            iFs ;
    CFbsBitmap*    iBitmap ;
    CFbsBitmap*    iMask ;
    TState         iState ;
    TSize          iImageSize ;
    CImageDecoder* iImageDecoder;
    CBitmapScaler* iScaler ;
    HBufC8*        iDecodeData ;
    TBool          iDecodeFinish ;
};

#endif  /* PDIMAGEDECODER_H */

/* End of File */
